<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>电影列表</title>
    <style type="text/css">
        h3{
            text-align: center;
        }
        table#table1{
            margin:10px auto;
            width: 60%;
            border: 1px solid black;
        }
        table#table1 tr th,td {
            border: 1px solid black;
            text-align: center;
        }
        .beige{
            background-color: beige;
        }
        .white{
            background-color: white;
        }

    </style>
</head>
<body>
<h3>电影列表</h3>
<table id="table1">
    <thead>
    <tr>
        <th>电影编号</th>
        <th>电影名称</th>
        <th>电影价格</th>
        <th>status.index</th>
        <th>status.count</th>
        <th>status.odd</th>
        <th>status.even</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <tr th:if="${#lists.isEmpty(movieList)}">
        <td colspan="8">
            对不起,米钱没有一部要放映的电影,欢迎持续关注.
        </td>
    </tr>
    <tr th:if="${movieList!=null && movieList.size()>0}"
        th:each="movie:${movieList}"
        th:class="${movieStat.odd?'beige':'white'}">
        <td th:text="${movie.movieId}"></td>
        <td th:text="${movie.movieName}"></td>
        <td th:text="${movie.moviePrice}"></td>
        <td th:text="${movieStat.index}"></td>
        <td th:text="${movieStat.count}"></td>
        <td th:text="${movieStat.odd}"></td>
        <td th:text="${movieStat.even}"></td>
        <td>
            <a th:href="@{/movie/deleteMovieById(movieId=${movie.movieId})}">删除1</a>
            <!--
            href="javascript:void(0)" 阻止默认的跳转行为
            confirmDelete([[${movie.movieId}]]) thymeleaf往vue里面传参
            -->
            <a href="javascript:void(0)" th:onclick="confirmDelete([[${movie.movieId}]])">删除2</a>
            <a th:href="@{/movie/getMovieById(movieId=${movie.movieId})}">修改</a>
        </td>
    </tr>
    </tbody>
    <tfoot>
    <tr>
        <td colspan="8">
            <a th:href="@{/movie/toAdd}">添加电影信息</a>
        </td>
    </tr>
    </tfoot>
</table>
</body>
<script>
    function confirmDelete(movieId) {
        var flag = window.confirm("您确定删除该电影吗?[movieId = " + movieId + "]");
        if (flag) {
            window.location.href = "/moviemgr/movie/deleteMovieById?movieId=" + movieId;
        }
    }
</script>
</html>